package com.ruoyi.web.controller.system;

import java.util.ArrayList;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.Advice;
import com.ruoyi.system.service.IAdviceService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 【请填写功能名称】Controller
 * 
 * @author ruoyi
 * @date 2023-03-03
 */
@RestController
@RequestMapping("/system/advice")
public class AdviceController extends BaseController
{
    @Autowired
    private IAdviceService adviceService;

    /**
     * 查询【请填写功能名称】列表
     */
    @PreAuthorize("@ss.hasPermi('system:advice:list')")
    @GetMapping("/list")
    public TableDataInfo list(Advice advice)
    {
        startPage();
        return getDataTable(adviceService.selectAdviceList(advice));
    }

    /*
    * 查询列表
    * */
    @GetMapping("/adviceList")
    public TableDataInfo adviceList()
    {
        return getDataTable(adviceService.adviceList());
    }
/*
    * 查询列表
    * */
    @GetMapping("/noReply")
    public TableDataInfo getNoReplyAdvice()
    {
        return getDataTable(adviceService.noReplyAdvice());
    }

    /**
     * 导出【请填写功能名称】列表
     */
    @PreAuthorize("@ss.hasPermi('system:advice:export')")
    @Log(title = "纳税咨询导出Excel", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Advice advice)
    {
        List<Advice> list = adviceService.selectAdviceList(advice);
        ExcelUtil<Advice> util = new ExcelUtil<Advice>(Advice.class);
        util.exportExcel(response, list, "纳税咨询数据");
    }

    /**
     * 获取【请填写功能名称】详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:advice:query')")
    @GetMapping(value = "/{adviceId}")
    public AjaxResult getInfo(@PathVariable("adviceId") Long adviceId)
    {
        return success(adviceService.selectAdviceByAdviceId(adviceId));
    }

    /**
     * 新增【请填写功能名称】
     */
    @PreAuthorize("@ss.hasPermi('system:advice:add')")
    @Log(title = "纳税咨询新增", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Advice advice)
    {
        return toAjax(adviceService.insertAdvice(advice));
    }

    /**
     * 修改【请填写功能名称】
     */
    @PreAuthorize("@ss.hasPermi('system:advice:edit')")
    @Log(title = "纳税咨询修改", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Advice advice)
    {
        return toAjax(adviceService.updateAdvice(advice));
    }

    /**
     * 删除【请填写功能名称】
     */
    @PreAuthorize("@ss.hasPermi('system:advice:remove')")
    @Log(title = "纳税咨询删除", businessType = BusinessType.DELETE)
	@DeleteMapping("/{adviceIds}")
    public int remove(@PathVariable Long[] adviceIds)
    {
        return adviceService.deleteAdviceByAdviceIds(adviceIds);
    }
}
